<template>
  <div class="home">
    <div class="search_warp">
      <span>地址关键词查询：</span>
      <el-input
        type="text"
        placeholder="请输入查询关键词"
        v-model="addressInput"
        id="searchInputId"
      />
      <el-button id="searchAddressBtn" @click="sendSearchInfo"
        >查询地址</el-button
      >
    </div>
    <!-- 地图 -->
    <div class="map_wrap">
      <MapContainer
        :addressInput="addressInput"
        ref="MapContainerbox"
      ></MapContainer>
    </div>
    <div class="heatMap_wrap">
      <el-radio-group class="heatMap_Box" v-model="checked">
        <el-radio @change="radioSend" border :label="false">默认地图</el-radio>
        <el-radio @change="radioSend" border :label="true">热力图</el-radio>
        <!-- <el-radio  @change="radioSend" border :label='true'
          >备选项</el-radio
        > -->
      </el-radio-group>
    </div>
  </div>
</template>

<script>
import MapContainer from '@/components/MapContainer/MapContainer.vue'
export default {
  name: 'HomeView',
  components: {
    MapContainer
  },
  data () {
    return {
      addressInput: '', // 输入的地址
      // searchInputId: 'searchInputId',
      checked: false,
      zero: 'zero',
      hot: 'hot'
    }
  },
  methods: {
    sendSearchInfo () {
      // this.$refs.MapContainerbox.addressInput = this.addressInput
      this.$refs.MapContainerbox.searchPlaceApi(this.addressInput)
      // this.$refs.MapContainerbox.drawBounds()
    },
    radioSend () {
      this.$store.state.showHotStatus = this.checked
      console.log(this.checked)
      if (this.checked === true) {
        console.log(this.checked, true)
        this.$refs.MapContainerbox.showHeat()
      } else {
        console.log(this.checked, false)
      }
    }
  },
  mounted () {
    this.$store.state.searchInputId = this.searchInputId
  }
}
</script>

<style lang="less" scoped>
.home {
  height: 100%;
  width: 100%;
  margin: 20px;
  .map_wrap {
    height: 400px;
    width: 100%;
  }
  .search_warp {
    display: flex;
    align-items: center;
    margin: 10px 0;
    .el-input {
      width: 300px;
    }
    #searchAddressBtn {
      margin-left: 5px;
      // background: linear-gradient(90deg,rgb(87, 177, 218),pink);
      // border: 0;
      // box-shadow: 0 0 1px 1px skyblue;
    }
  }
  .heatMap_wrap {
    position: absolute;
    top: 70px;
    left: 20px;
    .heatMap_Box {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: space-around;
      .el-radio {
        width: 100px;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: aliceblue;
        padding: 0;
        margin: 5px 0;
      }
    }
  }
}
/deep/.amap-sug-result {
  z-index: 9999;
}
</style>
